package com.ruoyi.tournament.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.firefighter.domain.FirefighterInfo;
import com.ruoyi.firefighter.service.IFirefighterInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tournament.mapper.FirefighterTournamentMapper;
import com.ruoyi.tournament.domain.FirefighterTournament;
import com.ruoyi.tournament.service.IFirefighterTournamentService;

/**
 * 比武竞赛情况Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Service
public class FirefighterTournamentServiceImpl implements IFirefighterTournamentService
{
    @Autowired
    private FirefighterTournamentMapper firefighterTournamentMapper;
    @Autowired
    private IFirefighterInfoService iFirefighterInfoService;
    /**
     * 查询比武竞赛情况
     *
     * @param id 比武竞赛情况主键
     * @return 比武竞赛情况
     */
    @Override
    public FirefighterTournament selectFirefighterTournamentById(Long id)
    {
        return firefighterTournamentMapper.selectFirefighterTournamentById(id);
    }

    /**
     * 查询比武竞赛情况列表
     *
     * @param firefighterTournament 比武竞赛情况
     * @return 比武竞赛情况
     */
    @Override
    public List<FirefighterTournament> selectFirefighterTournamentList(FirefighterTournament firefighterTournament)
    {
        return firefighterTournamentMapper.selectFirefighterTournamentList(firefighterTournament);
    }

    /**
     * 新增比武竞赛情况
     *
     * @param firefighterTournament 比武竞赛情况
     * @return 结果
     */
    @Override
    public int insertFirefighterTournament(FirefighterTournament firefighterTournament)
    {
        FirefighterInfo firefighterInfo1 = new FirefighterInfo();
        firefighterInfo1.setIdCardNumber(firefighterTournament.getFirefighterIdCard());
        FirefighterInfo firefighterInfo= iFirefighterInfoService.selectFirefighterInfoBySfz(firefighterInfo1);
        firefighterTournament.setFirefighterId(firefighterInfo.getUserId());
        firefighterTournament.setCreateTime(DateUtils.getNowDate());
        return firefighterTournamentMapper.insertFirefighterTournament(firefighterTournament);
    }

    /**
     * 修改比武竞赛情况
     *
     * @param firefighterTournament 比武竞赛情况
     * @return 结果
     */
    @Override
    public int updateFirefighterTournament(FirefighterTournament firefighterTournament)
    {
        firefighterTournament.setUpdateTime(DateUtils.getNowDate());
        return firefighterTournamentMapper.updateFirefighterTournament(firefighterTournament);
    }

    /**
     * 批量删除比武竞赛情况
     *
     * @param ids 需要删除的比武竞赛情况主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterTournamentByIds(Long[] ids)
    {
        return firefighterTournamentMapper.deleteFirefighterTournamentByIds(ids);
    }

    /**
     * 删除比武竞赛情况信息
     *
     * @param id 比武竞赛情况主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterTournamentById(Long id)
    {
        return firefighterTournamentMapper.deleteFirefighterTournamentById(id);
    }

    @Override
    public void deleteFirefighterTournamentById1(Long userId) {
        firefighterTournamentMapper.deleteFirefighterTournamentByIdsuser(userId);
    }
}
